{% load static %}
{% load i18n %}
{% load globalconfig_tags %}

<!DOCTYPE html>
{% get_current_language as LANGUAGE_CODE %}
<html lang="{{ LANGUAGE_CODE }}">
<head>
	<meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-4.4.1/css/bootstrap.min.css' %}">
	{% block page-head %}{% endblock %}
    <style>
        html{
            height: 100%;
            font-size: 0.9rem;
        }
        body{
            display: flex;
            flex-direction: column;
            height: 100%;
        }
        .page-header{
            flex: 0 0 auto;
        }
        .page-content {
            flex: 1 0 auto;
            padding-top: 10px;
            padding-bottom: 20px;
        }
        .page-footer{
            background: #ececec;
            flex: 0 0 auto;
            {#height:60px;#}
        }
    </style>
</head>
<body>
    <div class="page-header">
        {% block page-header %}{% endblock %}
    </div>
    <div class="page-content">
        {% block page-content %}{% endblock %}
    </div>
    <footer class="page-footer">
        <div class="text-center">
            <p>1996-{% now "Y" %} <a href="http://www.cnic.cas.cn/">中国科学院计算机网络信息中心</a> 版权所有 京ICP备09112257号-94.  Powered by 中国科技云
                <a href="{% if global_config %}{{ global_config.power_by }}
            {% else %} https://gitee.com/cstcloud-cnic/iharbor {% endif %}">iHarbor</a></p>
            <p>Copyright © 1996-{% now "Y" %} Computer Network Information Center, Chinese Academy of Sciences. All Rights Reserved.</p>
        </div>
    </footer>

</body>
    <script type="text/javascript" src="{% static 'jquery/jquery-3.7.1.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'bootstrap-4.4.1/js/bootstrap.bundle.min.js' %}"></script>
	<script type="text/javascript" src="{% static 'fontawesome-free/js/all.min.js' %}"></script>
    <script>

        document.addEventListener("DOMContentLoaded", function () {
            // 获取用户时区
            const useTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
            console.log("User Timezone:", useTimezone);
            let localStorageTimeZone = localStorage.getItem('useTimeZone')
            if (localStorageTimeZone === null || localStorageTimeZone === '') {
                localStorage.setItem('useTimeZone', useTimezone)
            } else if (useTimezone !== localStorageTimeZone) {
                localStorage.setItem('useTimeZone', useTimezone)
            }

            let serviceUseTineZone = "{{ request.session.useTimeZone }}"

            if (serviceUseTineZone === '' || serviceUseTineZone === null) {
                setServiceTimeZone(useTimezone)

            } else if (serviceUseTineZone !== localStorageTimeZone) {
                setServiceTimeZone(useTimezone)
            }

        });

        function setServiceTimeZone(useTimeZone) {

            $.ajax({
                url: '{% url 'timezone' %}',
                type: 'POST',
                async: false,
                data: {'timezone': useTimeZone},
                success: function (data) {
                    localStorage.setItem('useTimeZone', useTimeZone)
                },
                error: function (xhr) {
                    console.error("Error:", xhr);
                }
            })
        }
    </script>
    {% block page-script %}{% endblock %}
</html>